import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/login',
    name: 'Login',
    // 登录页面组件懒加载
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/',
    name: 'Layout',
    // 布局组件
    component: () => import('@/views/layout/index.vue'),
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: {
          title: 'Dashboard'
        }
      },
      {
        path: '/system/user',
        name: 'User',
        component: () => import('@/views/system/user/index.vue'),
        meta: {
          title: '用户管理'
        }
      },
      {
        path: '/system/role',
        name: 'Role',
        component: () => import('@/views/system/role/index.vue'),
        meta: {
          title: '角色管理'
        }
      },
      {
        path: '/system/menu',
        name: 'Menu',
        component: () => import('@/views/system/menu/index.vue'),
        meta: {
          title: '菜单管理'
        }
      },
      {
        path: '/product/category',
        name: 'category',
        component: () => import('@/views/product/category/index.vue'),
        meta: {
          title: '分类管理'
        }
      },
      {
        path: '/product/brand',
        name: 'brand',
        component: () => import('@/views/product/brand/index.vue'),
        meta: {
          title: '品牌管理'
        }
      },
      {
        path: '/product/attribute/attr-group',
        name: 'group',
        component: () => import('@/views/product/attribute/attr-group.vue'),
        meta: {
          title: '属性分组'
        }
      },
      {
        path: '/product/attribute/attr-specifications',
        name: 'specifications',
        component: () => import('@/views/product/attribute/attr-specifications.vue'),
        meta: {
          title: '规格参数'
        }
      },
      {
        path: '/product/attribute/attr-sales',
        name: 'sales',
        component: () => import('@/views/product/attribute/attr-sales.vue'),
        meta: {
          title: '销售属性'
        }
      },
      {
        path: '/product/maintenance/spu',
        name: 'spu',
        component: () => import('@/views/product/maintenance/spu.vue'),
        meta: {
          title: 'SPU管理'
        }
      },
      {
        path: '/product/maintenance/release',
        name: 'release',
        component: () => import('@/views/product/maintenance/release.vue'),
        meta: {
          title: '发布商品'
        }
      },
      {
        path: '/product/maintenance/management',
        name: 'management',
        component: () => import('@/views/product/maintenance/management.vue'),
        meta: {
          title: '商品管理'
        }
      },
      {
        path: '/member/list',
        name: 'list',
        component: () => import('@/views/member/list.vue'),
        meta: {
          title: '会员列表'
        }
      },
      {
        path: '/member/level',
        name: 'level',
        component: () => import('@/views/member/level.vue'),
        meta: {
          title: '会员等级'
        }
      },
      {
        path: '/member/variation',
        name: 'variation',
        component: () => import('@/views/member/variation.vue'),
        meta: {
          title: '积分变化'
        }
      },
      {
        path: '/member/statisticalInfo',
        name: 'statisticalInfo',
        component: () => import('@/views/member/statisticalInfo.vue'),
        meta: {
          title: '统计信息'
        }
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router
